unit FRM_CADASTRO_RESERVAS_QUARTOS;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DynamicSkinForm, SkinCtrls, SkinGrids, pngimage, ExtCtrls,
  Mask, DB, spDBGrids, SkinExCtrls;

type
  TForm10 = class(TForm)
    spDynamicSkinForm1: TspDynamicSkinForm;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    spSkinButton1: TspSkinButton;
    MaskEdit1: TMaskEdit;
    MaskEdit2: TMaskEdit;
    MaskEdit3: TMaskEdit;
    Image1: TImage;
    Edit4: TEdit;
    Edit5: TEdit;
    spSkinButton2: TspSkinButton;
    spSkinButton3: TspSkinButton;
    Image2: TImage;
    Edit6: TEdit;
    spSkinDBGrid1: TspSkinDBGrid;
    DataSource1: TDataSource;
    spSkinButtonEx1: TspSkinButtonEx;
    procedure FormCreate(Sender: TObject);
    procedure Image1Click(Sender: TObject);
    procedure Edit3Change(Sender: TObject);
    procedure spSkinButton1Click(Sender: TObject);
    procedure spSkinButton2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Image2Click(Sender: TObject);
    procedure Edit8Change(Sender: TObject);
  private
    { Private declarations }
  public
    var mode : string;
  end;

var
  Form10: TForm10;

implementation

uses DATA_MODULE, FRM_PROMPT_CLIENTE, FRM_LOGIN, FRM_CONSULTA_RESERVAS_QUARTOS,
  FRM_PROMPT_FORMAP;

{$R *.dfm}

procedure TForm10.Edit3Change(Sender: TObject);
var codigo_cliente : integer;
begin
  codigo_cliente := StrToInt(Edit3.Text);
  DataModule1.IB_SQL.SQL.Text := 'select clinome from clientes where clicodigo = :CODIGO';
  DataModule1.IB_SQL.ParamByName('CODIGO').AsInteger := codigo_cliente;
  DataModule1.IB_CLIENTES.StartTransaction;
  DataModule1.IB_SQL.ExecQuery;
  Edit5.Text := DataModule1.IB_SQL.FieldByName('clinome').AsString;
  DataModule1.IB_SQL.Close;
  DataModule1.IB_CLIENTES.Commit;


end;

procedure TForm10.Edit8Change(Sender: TObject);
var codigo_forma :integer;
begin
  codigo_forma := StrToInt(Edit8.Text);
  DataModule1.IB_SQL.SQL.Text := 'select forpagdescricao from formas_pagamento where forpagcodigo = :CODIGO';
  DataModule1.IB_SQL.ParamByName('CODIGO').AsInteger := codigo_forma;
  DataModule1.IB_FORMA_PAGAMENTO.StartTransaction;
  DataModule1.IB_SQL.ExecQuery;
  Edit6.Text := DataModule1.IB_SQL.FieldByName('forpagdescricao').AsString;
  DataModule1.IB_SQL.Close;
  DataModule1.IB_FORMA_PAGAMENTO.Commit;
end;

procedure TForm10.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  //action := caFree;
  //Form10 := Nil;
end;

procedure TForm10.FormCreate(Sender: TObject);
  var sequencial : integer;
  //var mode : string;
begin
  spSkinButton3.Visible := false;
  spSkinDBGrid1.Visible := false;
  Edit2.Text := Form1.NomeHotel;
  Edit4.Text := Form1.NomeUsuario;
//  mode := Form9.mode;
  if mode = 'INS' then
  begin
    MaskEdit2.Text:= dateTostr(time);
    sequencial := 0;
    DataModule1.IB_SQL.SQL.Text := 'select first 1 rescodigo from reservas_quartos order by rescodigo DESC';
//    DataModule1.IB_SQL.ParamByName('CODIGO').AsInteger := codigo_cliente;
    DataModule1.IB_RESERVAS_QUARTOS.StartTransaction;
    DataModule1.IB_SQL.ExecQuery;
    sequencial := DataModule1.IB_SQL.FieldByName('rescodigo').asinteger;
    showmessage(DataModule1.IB_SQL.FieldByName('rescodigo').asstring);
    DataModule1.IB_SQL.Close;
    DataModule1.IB_RESERVAS_QUARTOS.Commit;
    sequencial := sequencial + 1;
    Edit1.Text := IntTostr(sequencial);
    //DataModule1.IB_RESERVASQUARTOS.Insert;
  end;

  Edit1.Enabled := False;
  Edit2.Enabled := False;
  Edit4.Enabled := False;

end;

procedure TForm10.Image1Click(Sender: TObject);
begin
Form11.ShowModal;
end;

procedure TForm10.Image2Click(Sender: TObject);
begin
  Form12.ShowModal;
end;

procedure TForm10.spSkinButton1Click(Sender: TObject);
begin
  spSkinButton3.Visible := True;
  spSkinDBGrid1.Visible := True;
end;

procedure TForm10.spSkinButton2Click(Sender: TObject);
begin
  close;
end;

end.
